home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / INCLUDE / VALUES.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  6KB  |  191 lines

  1. /* 
  2. Copyright (C) 1988 Free Software Foundation
  3.     written by Doug Lea (dl@rocky.oswego.edu)
  4.  
  5. This file is part of the GNU C++ Library.  This library is free
  6. software; you can redistribute it and/or modify it under the terms of
  7. the GNU Library General Public License as published by the Free
  8. Software Foundation; either version 2 of the License, or (at your
  9. option) any later version.  This library is distributed in the hope
  10. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  11. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE.  See the GNU Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17.  
  18.  
  19. #ifndef _VALUES_H
  20. #define _VALUES_H 1
  21.  
  22. #define __BITSPERBYTE 8
  23. #define __BITS(type)  (__BITSPERBYTE * (int)sizeof(type))
  24.   /* Rename the above to __BITS so it doesn't intrude on users' namespace? */
  25.  
  26. #ifndef BITS
  27. #define BITS(type) __BITS(type)
  28. #endif
  29.  
  30. #ifndef BITSPERBYTE
  31. #define BITSPERBYTE  __BITSPERBYTE
  32. #endif
  33.  
  34. #define CHARBITS    __BITS(char)
  35. #define SHORTBITS   __BITS(short)
  36. #define INTBITS     __BITS(int)
  37. #define LONGBITS    __BITS(long)
  38. #define PTRBITS     __BITS(char*)
  39. #define DOUBLEBITS  __BITS(double)
  40. #define FLOATBITS   __BITS(float)
  41.  
  42. #define MINSHORT    ((short)(1 << (SHORTBITS - 1)))
  43. #define MININT      (1 << (INTBITS - 1))
  44. #define MINLONG     (1L << (LONGBITS - 1))
  45.  
  46. #define MAXSHORT    ((short)~MINSHORT)
  47. #define MAXINT      (~MININT)
  48. #define MAXLONG     (~MINLONG)
  49.  
  50. #define HIBITS    MINSHORT
  51. #define HIBITL    MINLONG
  52.  
  53. #if defined(__sun__) || defined(hp300) || defined(hpux) || defined(masscomp) || defined(sgi) || defined (__mc68000__)
  54. #ifdef masscomp
  55. #define MAXDOUBLE                            \
  56. ({                                    \
  57.   double maxdouble_val;                            \
  58.                                     \
  59.   __asm ("fmove%.d #0x7fefffffffffffff,%0"    /* Max double */    \
  60.      : "=f" (maxdouble_val)                        \
  61.      : /* no inputs */);                        \
  62.   maxdouble_val;                            \
  63. })
  64. #define MAXFLOAT ((float) 3.40e+38)
  65. #else
  66. #define MAXDOUBLE   1.79769313486231470e+308
  67. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  68. #endif
  69. #define MINDOUBLE   4.94065645841246544e-324
  70. #define MINFLOAT    ((float)1.40129846432481707e-45)
  71. #define _IEEE       1
  72. #define _DEXPLEN    11
  73. #define _FEXPLEN    8
  74. #define _HIDDENBIT  1
  75. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  76. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  77. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  78. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  79.  
  80. #elif defined(sony) 
  81. #define MAXDOUBLE   1.79769313486231470e+308
  82. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  83. #define MINDOUBLE   2.2250738585072010e-308
  84. #define MINFLOAT    ((float)1.17549435e-38)
  85. #define _IEEE       1
  86. #define _DEXPLEN    11
  87. #define _FEXPLEN    8
  88. #define _HIDDENBIT  1
  89. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  90. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  91. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  92. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  93.  
  94. #elif defined(sequent)
  95. extern double _maxdouble, _mindouble;
  96. extern float _maxfloat, _minfloat;
  97. #define MAXDOUBLE    _maxdouble
  98. #define MAXFLOAT    _maxfloat
  99. #define MINDOUBLE    _mindouble
  100. #define MINFLOAT    _minfloat
  101. #define _IEEE       1
  102. #define _DEXPLEN    11
  103. #define _FEXPLEN    8
  104. #define _HIDDENBIT  1
  105. #define DMINEXP     (-(DMAXEXP - 3))
  106. #define FMINEXP     (-(FMAXEXP - 3))
  107. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  108. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  109.  
  110. #elif defined(__i386__)
  111. #define MAXDOUBLE   1.79769313486231570e+308
  112. #if 0
  113. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  114. #define MINDOUBLE   2.22507385850720140e-308
  115. #define MINFLOAT    ((float)1.17549435082228750e-38)
  116. #else
  117. #define MAXFLOAT    3.40282347e+38F
  118. #define MINDOUBLE   4.94065645841246544e-324
  119. #define MINFLOAT    1.40129846e-45F
  120. #endif
  121. #define _IEEE       1
  122. #define _DEXPLEN    11
  123. #define _FEXPLEN    8
  124. #define _HIDDENBIT  1
  125. #define DMINEXP     (-DMAXEXP)
  126. #define FMINEXP     (-FMAXEXP)
  127. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  128. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  129.  
  130. /* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
  131. #elif defined(m88k)
  132.     /* These are "good" guesses ...
  133.        I'll figure out the true mins and maxes later, at the time I find
  134.        out the mins and maxes that the compiler can tokenize. */
  135. #define MAXDOUBLE   1.79769313486231e+308
  136. #define MAXFLOAT    ((float)3.40282346638528e+38)
  137. #define MINDOUBLE   2.22507385850720e-308
  138. #define MINFLOAT    ((float)1.17549435082228e-38)
  139. #define _IEEE       1
  140. #define _DEXPLEN    11
  141. #define _FEXPLEN    8
  142. #define _HIDDENBIT  1
  143. #define DMINEXP     (1-DMAXEXP)
  144. #define FMINEXP     (1-FMAXEXP)
  145. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  146. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  147.  
  148. #elif defined(convex)
  149. #define MAXDOUBLE   8.9884656743115785e+306
  150. #define MAXFLOAT    ((float) 1.70141173e+38)
  151. #define MINDOUBLE   5.5626846462680035e-308
  152. #define MINFLOAT    ((float) 2.93873588e-39)
  153. #define _IEEE       0
  154. #define _DEXPLEN    11
  155. #define _FEXPLEN    8
  156. #define _HIDDENBIT  1
  157. #define DMINEXP     (-DMAXEXP)
  158. #define FMINEXP     (-FMAXEXP)
  159. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  160. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  161.  
  162. /*
  163. #elif defined(__vax__)
  164. use vax versions by default -- they seem to be the most conservative
  165. */
  166.  
  167. #else 
  168.  
  169. #define MAXDOUBLE   1.701411834604692293e+38
  170. #define MINDOUBLE   (2.938735877055718770e-39)
  171.  
  172. #define MAXFLOAT    1.7014117331926443e+38
  173. #define MINFLOAT    2.9387358770557188e-39
  174.  
  175. #define _IEEE       0
  176. #define _DEXPLEN    8
  177. #define _FEXPLEN    8
  178. #define _HIDDENBIT  1
  179. #define DMINEXP     (-DMAXEXP)
  180. #define FMINEXP     (-FMAXEXP)
  181. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  182. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  183. #endif
  184.  
  185. #define DSIGNIF     (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
  186. #define FSIGNIF     (FLOATBITS  - _FEXPLEN + _HIDDENBIT - 1)
  187. #define DMAXPOWTWO  ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
  188. #define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
  189.  
  190. #endif
  191.